<!DOCTYPE html>
<html>

<head>
    <#include "/xhc/admin/components/meta.html" />
    <title>出出帮火车奇妙世界后台 ${metaTitleSuffix!}</title>
    <#include "/xhc/admin/components/stylesheets.html" />
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="1-2" />
            <#include "/xhc/admin/components/menu.html" />
            <el-container>
                <#include "/xhc/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-row :gutter="20">
                            <el-col :span="4">
                                <el-button @click='onAdd'>添加</el-button>
                            </el-col>
                        </el-row>
                        <el-table :data="items" style="width: 100%">
                            <el-table-column prop="cover" label="封面">
                                <template slot-scope="scope">
                                    <img :src="scope.row.cover" style="width: 50px;height: 50px">
                            </template>
                            </el-table-column>
                            <el-table-column prop="title" label="标题">
                            </el-table-column>
                            <el-table-column prop="tips" label="">
                            </el-table-column>
                            <el-table-column prop="price" label="价格">
                            </el-table-column>
                            <el-table-column prop="count" label="库存">
                            </el-table-column>
                            <el-table-column label="操作">
                                <template slot-scope="scope">
                                    <a :href ="'/xhc/web/present/info?id='+scope.row.id">查看</a>
                                    <el-button @click='onDelete(scope.row)' type="danger" size='small'>删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <#include '/components/page.html' />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/xhc/admin/components/footer.html" />
    </div>
    <#include "/xhc/admin/components/scripts.html" />
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                items: toJson(`${items![]}`)
            }
        },
        mounted: function() {},
        methods: {
            onAdd() {
                window.location.href = '/xhc/web/present/info'
            },
            onDelete(item) {
                this.$confirm('确认删除, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var params = {
                        id: item.id
                    }
                    var url = '/xhc/web/present/delete'
                    axiosRequest(params, url, '${ref!""}')
                }).catch(() => {});
            },
        },
        filters: {
            fmt(date) {
                return date
            }
        }
    })
    </script>
    <script>
    // vue.tableData = ${items!};
    </script>
</body>

</html>